package com.example.demo.common;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lishuo
 * Date: 2023-09-16
 * Time: 15:55
 */
// 统一返回对象
@Data
public class ResultAjax {
    private int code;
    private String meg;
    private Object data;

    public static ResultAjax succ(Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(200);
        result.setMeg("");
        result.setData(data);
        return result;
    }

    public static ResultAjax succ(String meg,Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(200);
        result.setMeg(meg);
        result.setData(data);
        return result;
    }

    public static ResultAjax fail(String meg) {
        ResultAjax result = new ResultAjax();
        result.setData(-1);
        result.setMeg(meg);
        result.setData(null);
        return result;
    }

    public static ResultAjax fail(String meg,Object data) {
        ResultAjax result = new ResultAjax();
        result.setData(-1);
        result.setMeg(meg);
        result.setData(data);
        return result;
    }
}
